<?php
namespace Home\Model;
use Think\Model;
class ClassModel extends Model{
    protected $_auto = array (
               array('status',1),  // 新增时 status 1
               array('class_id',0),  // 新增时 cid 0
               array('is_delete',0),   
               array('number',0),  
               array('create_time','time',1,'function'), // 写入当前时间戳
    );
    protected $_validate = array(
        array('name','require','班级名称为空！',self::MUST_VALIDATE) // 名称
    );

    public function listMap( $map = array() , $limit = '0,10')
    {
      return $this->where( $map )->limit( $limit )->select();
    }
    public function findAll()
    {
      return $this->where(array(
          'is_delete'=>0,
          'status'=>array('egt',0)
        ))->select();
    }
    public function countMap($map=array())
    {
      return $this->where($map)->count();
    }

    public function find_by_id($id=null)
    {
      if (is_null($id)) {
        return array();
      } else {
        return $this->where(array('id'=>$id))->find();
      }
    }
}